package org.nepu.scr.indexrate.converter.drillingrate.keydevice.rotationsystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.rotationsystem.RotationDevice;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class RotationDeviceConverter implements AttributeConverter<RotationDevice, String> {
    @Override
    public String convertToDatabaseColumn(RotationDevice rotationDevice) {
        return JSONUtil.toJsonStr(rotationDevice);
    }

    @Override
    public RotationDevice convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, RotationDevice.class);
    }
}
